package com.homedo.odin.solution.controller.mng;


import com.homedo.core.common.base.controller.BaseController;
import com.homedo.core.common.base.dto.ResultData;
import com.homedo.odin.solution.contract.mng.BrandFirmDetailMngResp;
import com.homedo.odin.solution.contract.oms.BrandFirmListReq;
import com.homedo.odin.solution.contract.oms.BrandFirmListResp;
import com.homedo.odin.solution.contract.oms.UpdateBrandFirmReq;
import com.homedo.odin.solution.model.entity.UserScoreLevel;
import com.homedo.odin.solution.service.UserScoreLevelServiceImpl;
import com.homedo.odin.solution.service.bizservice.mng.MngBrandFirmBizService;
import com.homedo.odin.solution.service.bizservice.pc.UserInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(description = "用户信息", tags = {"UserInfo"}, produces = MediaType.APPLICATION_JSON_VALUE)
@RestController
@RequestMapping("/mng/user_info")
public class MngUserInfoController extends BaseController<UserInfoService> {

    @Autowired
    private MngBrandFirmBizService brandFirmBizService;

    @Autowired
    private UserScoreLevelServiceImpl userScoreLevelService;

    @ApiOperation(value = "OMS_更新品牌商审核状态", notes = "OMS_更新品牌商审核状态", httpMethod = "PUT")
    @PutMapping("/brand_firms/{userId}")
    public ResultData updateBrandFirm(@ApiParam(value = "用户id", required = true) @PathVariable("userId") int userId,
            @RequestBody UpdateBrandFirmReq req) {
        brandFirmBizService.userBrandAudit(req, userId);
        return ResultData.newInstance();
    }

    @ApiOperation(value = "OMS_获取品牌商信息详情", notes = "OMS_获取品牌商信息详情", response = BrandFirmDetailMngResp.class)
    @GetMapping("/brand_firms/{userId}")
    public ResultData getBrandFirm(@ApiParam("用户ID") @PathVariable("userId") Integer userId) {
        return ResultData.newInstance(brandFirmBizService.findBrandFirmByUserId(userId));
    }

    @ApiOperation(value = "OMS_获取品牌商分页列表", notes = "OMS_获取品牌商分页列表", response = BrandFirmListResp.class, httpMethod = "GET")
    @GetMapping("/brand_firms")
    public ResultData getBrandFirmList(@ModelAttribute("req") BrandFirmListReq req) {
        return ResultData.newInstance(brandFirmBizService.getBrandFirmList(req));
    }

    @ApiOperation(value = "OMS_获取所有用户等级", notes = "OMS_获取所有等级", response = UserScoreLevel.class, httpMethod = "GET")
    @GetMapping("/level")
    public ResultData getAllUserLevel() {
        return ResultData.newInstance(userScoreLevelService.findAll());
    }
}
